/**
 * strings for all outlined grammars designed for LL(1) parsing.
 * Each grammar string is structured for efficient LL(1) parse method application, 
 * facilitating straightforward syntactic analysis and ensuring compatibility with 
 * LL(1) parsing requirements.
 * huizi 2024
 */
const Productions = (()=>{
    const productions = [];
    program(productions);
    assists(productions);
    imports(productions);
    exports(productions);
    statements(productions);
    extension(productions);
    return Object.freeze(productions);
})();

function program(productions){
    productions.push(`PROGRAM->IMPORT_DECLARES STATEMENTS EXPORT_DECLARE`);
}

function assists(productions){
    productions.push(`AS'->ε| as ID`);
    productions.push(`IDS_AS'-> ID AS' MORE_IDS_AS'`);
    productions.push(`MORE_IDS_AS'-> ε|,IDS_AS'`);
}

function imports(productions){
    productions.push(`IMPORT_DECLARES-> ε|IMPORT_DECLARE IMPORT_DECLARES`);
    productions.push(`IMPORT_DECLARE-> import {IMPORTS'} from ID`;);
    productions.push(`IMPORTS'-> IMPORT_ALL'|IDS_AS'`);
    productions.push(`IMPORT_ALL'-> * AS'`);
}

function exports(productions){
    productions.push(`EXPORT_DECLARE->ε|export {IDS_AS'};`); 
}

function statements(productions){
    productions.push(`STATEMENTS->ε|STATEMENT STATEMENTS`);
    productions.push(`STATEMENT->EXTENSION_STATEMENT
        |VAR_STATEMENT
        |LET_STATEMENT
        |RETURN_STATEMENT
        |IF_STATEMENT
        |DO_STATEMENT|WHILE_STATEMENT
        |FOR_STATEMENT|EACH_STATEMENT|EXPRESSION_STATEMENT|LOOP_CONTROL|COMMENT_STATEMENT
        |MATCH_STATEMENT`);
}

function extension(productions){
    productions.push("EXTENSION_STATEMENT->EXTENDED' ENTITY_BODY");
    productions.push(
                "EXTENDED'-> STRING_TYPE|NUMBER_TYPE|BOOL_TYPE|ARRAY_TYPE|MAP_TYPE|FUNCTION_TYPE|OBJECT_TYPE");
}

export {Productions};